#include <iostream>
#include "../../common/person.h"

//操作符重载
class older_than {
    public:
        older_than(int limit):m_limit(limit)
        {

        }
        // 函数对象重载 " () "操作符，在这个操作符中实现具体的函数功能
        // 这使得这个类的对象成为函数对象
        bool operator()(const person_t & person) const
        {
            return person.age() > m_limit;
        }
        private:
            int m_limit;
};
int main(int argc, char *argv[])
{
   person_t person("wang",person_t::male, 35);

  older_than older_than_42 (42);
  older_than older_than_14 (14);

  if (older_than_42( person )) {
    std::cout << person.name() << " is more than 42 years old\n";
  }
  else if (older_than_14( person ))
  {
    std::cout << person.name() << " is more than 14 years old\n";
  } else {
    std::cout << person.name() << " is 14 years old, or younger\n";
  }
}